//
//  CalendarDemoViewController.swift
//  ZZUIDemo
//
//  Created by 张文晏 on 2018/11/20.
//  Copyright © 2018 Newcoretech. All rights reserved.
//

import UIKit
import ZZUI

class CalendarDemoViewController: UIViewController {
    
    @IBOutlet var singleBtn: UIButton!
    @IBOutlet var sequenceBtn: UIButton!
    
    var selectedSingleDate = Date().formated() {
        didSet {
            singleBtn.setTitle(selectedSingleDate.string(), for: .normal)
        }
    }
    var selectedSequenceDate = (Date().formated(), Date().formated()) {
        didSet {
            sequenceBtn.setTitle("\(selectedSequenceDate.0.string()) 至 \(selectedSequenceDate.1.string())", for: .normal)
        }
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let date = Date().formated()
        
        singleBtn.setTitle(date.string(), for: .normal)
        sequenceBtn.setTitle("\(date.string()) 至 \(date.string())", for: .normal)
    }
    
    @IBAction func singleAction(_ sender: UIButton) {
        NCCalendar.showSingleMode(selectedDate: selectedSingleDate) { date in
            self.selectedSingleDate = date
        }
    }
    
    @IBAction func sequenceActions(_ sender: UIButton) {
        NCCalendar.showSequenceMode(selectedDates: (selectedSequenceDate.0, selectedSequenceDate.1)) { (start, end) in
            self.selectedSequenceDate = (start, end)
        }
    }
    
}
